package Demo2;
class MyValue{
    public int val;
}

public class Test1 {
    public static void swap(MyValue mv1,MyValue mv2){
        int tmp= mv1.val;
        mv1.val=mv2.val;
        mv2.val=tmp;
    }
    public static void main(String[] args) {
        MyValue myValue1=new MyValue();
        MyValue myValue2=new MyValue();
        myValue1.val=10;
        myValue2.val=20;
        System.out.println("交换前"+myValue1.val+" "+myValue2.val);
        swap(myValue1,myValue2);
        System.out.println("交换后"+myValue1.val+" "+myValue2.val);

    }
}
